<div class="row">
    <div class="col-lg-12">
        <div class="box">
            <div class="box-header">
                <a class="btn btn-app" data-toggle="modal" data-target="#expenditure_add">
                    <i class="fa fa-plus"></i> 填写支出单
                </a>
            </div><!-- /.box-header -->
            <div class="modal fade modal" id="expenditure_add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content table-responsive">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">填写支出单</h4>
                        </div>
                        <div class="modal-body">

                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        支出时间
                                    </div>
                                    <input class="form-control" type="text" autocomplete="off" placeholder="请输入支出时间" value="<?php echo date("Y-m-d H:i:s"); ?>" id="expenditure_time"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        摘要及用途
                                    </div>
                                    <input class="form-control" type="text" autocomplete="off" placeholder="摘要及用途" id="expenditure_text"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        金额（元）
                                    </div>
                                    <input class="form-control" type="text" autocomplete="off" placeholder="金额（元）" id="expenditure_price"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        经手人名字
                                    </div>
                                    <input class="form-control" type="text" autocomplete="off" placeholder="经手人名字" id="expenditure_name"/>
                                </div>
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-success pull-right" data-dismiss="modal" onclick='expenditure_add()'>提交</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-body">
                <div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
                    <div class="row">
                        <div class="col-sm-6"></div>
                        <div class="col-sm-6"></div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12">
                            <table class="table table-bordered table-hover dataTable">
                                <thead>
                                <tr role="row">
                                    <th>时间</th>
                                    <th>申报人</th>
                                    <th>内容</th>
                                    <th>金额</th>
                                    <th>领导审核</th>
                                    <th>财务</th>
                                    <th>出纳</th>
                                    <th>状态</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php if ($data['list'] != NULL){?>
                                    <?php for ($i = 0; $i <= $data['list'][$i]; $i++){
                                        $color_v2 = $data['list'][$i]['v1'] == 1 ? "orange" : "grey";
                                        $color_v3 = $data['list'][$i]['v2'] == 1 ? "orange" : "grey";
                                        $color_s = $data['list'][$i]['v3'] == 1 ? "orange" : "grey";
                                        $id = $data['list'][$i]['id'];?>
                                        <tr>
                                            <td><?php echo $data['list'][$i]['itime'];?></td>
                                            <td><?php echo $data['list'][$i]['name'];?></td>
                                            <td><?php echo $data['list'][$i]['content'];?></td>
                                            <td><?php echo $data['list'][$i]['money'];?></td>
                                            <td>
                                                <?php
                                                    switch ($data['list'][$i]['v1'])
                                                    {
                                                        case '0':
                                                            if ($_SESSION['RID'] == 0){
                                                                echo '<button class="btn btn-success btn-sm" onclick="expenditure_set(1,1,'.$id.')">通过</button> ';
                                                                echo '<button class="btn btn-danger btn-sm" onclick="expenditure_set(1,3,'.$id.')">拒绝</button>';
                                                            }
                                                            else {
                                                                echo '<b style="color:orange;">待处理</b>';
                                                            }
                                                            break;
                                                        case '1':
                                                            if ($_SESSION['RID'] == 0){
                                                                echo '<b style="color:green;">已确定</b> ';
                                                                echo '<button class="btn btn-warning btn-sm" onclick="expenditure_set(1,0,'.$id.')">取消</button>';
                                                            }
                                                            else {
                                                                echo '<b style="color:green;">已通过</b> ';
                                                            }
                                                            break;
                                                        case "3":
                                                            if ($_SESSION['RID'] == 0){
                                                                echo '<b style="color:red;">已拒绝</b> ';
                                                                echo '<button class="btn btn-warning btn-sm" onclick="expenditure_set(1,0,'.$id.')">取消</button>';
                                                            }
                                                            else {
                                                                echo '<b style="color:red;">申请失败</b>';
                                                            }
                                                            break;
                                                    }
                                                ?>
                                            </td>
                                            <td>
                                                <?php
                                                    switch ($data['list'][$i]['v2'])
                                                    {
                                                        case '0':
                                                            if ($_SESSION['RID'] == 4){
                                                                echo '<button class="btn btn-success btn-sm" onclick="expenditure_set(2,1,'.$id.')">已上报</button> ';
                                                            }
                                                            else {
                                                                echo '<b style="color:'.$color_v2.';">待处理</b>';
                                                            }
                                                            break;
                                                        case '1':
                                                            echo '<b style="color:green;">已上报</b>';
                                                            break;
                                                    }
                                                ?>
                                            </td>
                                            <td>
                                                <?php
                                                    switch ($data['list'][$i]['v3'])
                                                    {
                                                        case '0':
                                                            if ($_SESSION['RID'] == 5){
                                                                echo '<button class="btn btn-success btn-sm" onclick="expenditure_set(3,1,'.$id.')">已打款</button> ';
                                                            }
                                                            else {
                                                                echo '<b style="color:'.$color_v3.';">待处理</b>';
                                                            }
                                                            break;
                                                        case '1':
                                                            echo '<b style="color:green;">已打款</b>';
                                                            break;
                                                    }
                                                ?>
                                            </td>
                                            <td>
                                                <?php
                                                    switch ($data['list'][$i]['start'])
                                                    {
                                                        case '0':
                                                            echo '<b style="color:'.$color_s.';">待处理</b>';
                                                            break;
                                                        case '1':
                                                            echo '<b style="color:green;" >已收款</b>';
                                                            break;
                                                        case '4':
                                                            if ($_SESSION['uname'] == $data['list'][$i]['name']){
                                                                echo '<button class="btn btn-success btn-sm" onclick="expenditure_set(4,1,'.$id.')">已收款</button> ';
                                                            }
                                                            else {
                                                                echo '<b style="color:blue;">等待申报人确认收款</b>';
                                                            }
                                                            break;
                                                    }
                                                if ($data['list'][$i]['v1'] == 3){
                                                    if ($_SESSION['RID'] == 0){
                                                        echo ' <button class="btn btn-danger btn-sm" onclick="expenditure_set(5,1,'.$id.')">删除</button> ';
                                                    }
                                                }
                                                ?>
                                            </td>
                                        </tr>
                                    <?php } }else{?>
                                    <tr>
                                        <td colspan="8">
                                            <div class="alert alert-info" role="alert" style="text-align: center;font-size: 2em;">
                                                目前暂无进行中的报销项目
                                            </div>
                                        </td>
                                    </tr>
                                    <?php }?>
                                </tbody>
                                <tfoot>
                                <tr role="row">
                                    <th>时间</th>
                                    <th>申报人</th>
                                    <th>内容</th>
                                    <th>金额</th>
                                    <th>领导审核</th>
                                    <th>财务</th>
                                    <th>出纳</th>
                                    <th>状态</th>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div><!-- /.box-body -->
            </div>
        </div>
    </div>
</div>